package vistas.estructuras;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Image;
import javax.swing.ImageIcon;

public class ContenedorCalleVertical extends ContenedorCalle {
    Image imagen;
    Panel panel;
    
    public ContenedorCalleVertical() {
        super();
        setPreferredSize(new Dimension(50, 25));
        setBackground(new Color(128, 128, 128));
    }
    
    
    @Override
    public void agregarObstruccion (String nombreObstruccion) {
        if (this.panel == null) {
            this.panel = new Panel();
            this.panel.setPreferredSize(new Dimension(50, 25));
            this.panel.setBackground(new Color(128, 128, 128));
            this.panel.setLayout(new GridLayout(0, 1, 2, 2));
            this.add(this.panel);
        }
        
        Panel obstruccion = new Panel();
        obstruccion.setPreferredSize(new Dimension(25, 25));
    
        try {
           Image imagenObstruccion = new ImageIcon(".\\src\\vistas\\estructuras\\imagenes\\Obstrucciones\\" + nombreObstruccion + ".png").getImage();
           obstruccion.setImagen(imagenObstruccion);
        } catch (Exception e) {
           System.out.println("Error en asignar imagen al panel!");
        }
        
        this.panel.add(obstruccion);
    }
}
